package day19.zhiyou200;

public class TestThread01 implements Runnable{

    private int ticketNums = 10;

    @Override
    public void run() {
        while (true) {
            if (ticketNums <= 0) {
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"拿到了第" + ticketNums-- + "票");
        }
    }

    public static void main(String[] args) {
        TestThread01 ticket = new TestThread01();
        new Thread(ticket,"001").start();
        new Thread(ticket,"002").start();
        new Thread(ticket,"003").start();
    }
}
